﻿
Partial Class _Default
    Inherits System.Web.UI.Page

    Public Property VarSession() As Integer
        Get
            If CStr(Session("var1")) = "" Then
                Return 0
            Else
                Return Session("var1")
            End If
        End Get
        Set(ByVal value As Integer)
            Session("var1") = value
        End Set
    End Property


    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim userlogin As New EsportsLn.Usuari

        If userlogin.login(Login.Text, Password.Text) Then
            lblResposta.Visible = False
            '1 . SET la variable
            Session("logincorrecte") = True
            Session("loginnom") = "Ferran"

            Server.Transfer("Home2.aspx")
            'Response.Redirect("Home.aspx?val1=eee&val2=oooo")
        Else
            Session("logincorrecte") = False

            'Variable de estat de vista
            Dim var1 As Integer = 0
            If CStr(ViewState("a")) <> "" Then
                var1 = CInt(ViewState("a"))
                'ViewState.Add("a", var1)
            End If
            var1 += 1
            VarSession += 2
            ViewState("a") = var1
            IntentInicial.Checked = False
            IntentInicial.Text = "intents " & var1 & " " & VarSession
            lblResposta.Visible = True
            lblResposta.Text = "Aquest login o password no son correctes " & Login.Text
        End If

    End Sub

    Public Function Funcio1(ByVal Parametre1 As String, ByVal paremetre2 As Integer) As String

        Dim i As Integer = 0
        Dim res As String = ""

        'for (int i=0;i<paremtre2;i++){}
        For i = 0 To paremetre2 Step 1
            res += Parametre1 + " " + CStr(i)

        Next

        i = 0
        While i < paremetre2
            ' TODO
            If (i > 1 And res.Length < 90) Or (i > 80) Then
                res += "____ "
            End If
            i += 1
            Select Case i
                Case 1
                    res += "uno"
                Case 2
                    res += "dos "
                Case Else
            End Select
        End While
        Return res
    End Function

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not IsPostBack Then
            IntentInicial.Checked = True
            IntentInicial.Text = Funcio1("hello ", 5)
            '        Else
            '            IntentInicial.Checked = False
            lblResposta.Visible = True
        End If


    End Sub
End Class
